package com.situ.mall.controller.front;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.mall.common.ServerResponse;
import com.situ.mall.entity.Category;
import com.situ.mall.entity.Product;
import com.situ.mall.service.ICategoryService;

@Controller
public class FrontIndexController {
	//在这个里面写了各种跳转
	@Autowired
	private ICategoryService categoryService;
	
	//跳转到主页展示界面
	@RequestMapping("/index.shtml")
	public String index(Model model) {
		//前台查一级分类
		List<Category> topCategoryList = categoryService.selectTopCategoryList();
		System.out.println(topCategoryList);
		model.addAttribute("topCategoryList",topCategoryList);
		//前台查二级分类
		List<Category> secondCategoryList = categoryService.selectSecondCategoryList();
		System.out.println(secondCategoryList);
		model.addAttribute("secondCategoryList",secondCategoryList);
		
		return "/index";
	}
	
	//注销操作
	@RequestMapping("/remove.shtml")
	@ResponseBody
	public ServerResponse remove(HttpSession session) {
		session.invalidate();
		//局部刷新?
		return ServerResponse.createSuccess("注销成功");
	}
	
	

}
